/*
               File: ModReg
        Description: Modificar Registro
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 14:58:58.65
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class pmodreg extends GXProcedure
{
   public pmodreg( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( pmodreg.class ), "" );
   }

   public pmodreg( int remoteHandle ,
                   ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( int aP0 ,
                        String aP1 ,
                        String aP2 ,
                        String aP3 ,
                        String aP4 ,
                        byte[] aP5 )
   {
      execute_int(aP0, aP1, aP2, aP3, aP4, aP5);
   }

   private void execute_int( int aP0 ,
                             String aP1 ,
                             String aP2 ,
                             String aP3 ,
                             String aP4 ,
                             byte[] aP5 )
   {
      pmodreg.this.AV8Codigo = aP0;
      pmodreg.this.AV11Descri = aP1;
      pmodreg.this.AV12Estado = aP2;
      pmodreg.this.AV13Usuari = aP3;
      pmodreg.this.AV10Tabla = aP4;
      pmodreg.this.aP5 = aP5;
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      if ( ( GXutil.strcmp(AV10Tabla, "MMCMB10") == 0 ) )
      {
         AV9Pout = 0 ;
         /* Using cursor P00132 */
         pr_default.execute(0, new Object[] {new Integer(AV8Codigo)});
         while ( (pr_default.getStatus(0) != 101) )
         {
            A523CmbCod = P00132_A523CmbCod[0] ;
            A578CmbNom = P00132_A578CmbNom[0] ;
            A579CmbEst = P00132_A579CmbEst[0] ;
            A585CmbUUM = P00132_A585CmbUUM[0] ;
            A583CmbFUM = P00132_A583CmbFUM[0] ;
            A584CmbHUM = P00132_A584CmbHUM[0] ;
            A578CmbNom = GXutil.upper( GXutil.trim( AV11Descri)) ;
            A579CmbEst = AV12Estado ;
            A585CmbUUM = AV13Usuari ;
            A583CmbFUM = GXutil.serverDate( context, remoteHandle, "DEFAULT") ;
            A584CmbHUM = GXutil.serverTime( context, remoteHandle, "DEFAULT") ;
            AV9Pout = (byte)(1) ;
            /* Using cursor P00133 */
            pr_default.execute(1, new Object[] {A578CmbNom, A579CmbEst, A585CmbUUM, A583CmbFUM, A584CmbHUM, new Integer(A523CmbCod)});
            /* Check if program is canceled. */
            /* Exiting from a For First loop. */
            if (true) break;
         }
         pr_default.close(0);
      }
      else if ( ( GXutil.strcmp(AV10Tabla, "MMTAU10") == 0 ) )
      {
         AV9Pout = 0 ;
         /* Using cursor P00134 */
         pr_default.execute(2, new Object[] {new Integer(AV8Codigo)});
         while ( (pr_default.getStatus(2) != 101) )
         {
            A376TipAut = P00134_A376TipAut[0] ;
            A377TipAut = P00134_A377TipAut[0] ;
            A378TipAut = P00134_A378TipAut[0] ;
            A384TipAut = P00134_A384TipAut[0] ;
            A382TipAut = P00134_A382TipAut[0] ;
            A383TipAut = P00134_A383TipAut[0] ;
            A377TipAut = GXutil.upper( GXutil.trim( AV11Descri)) ;
            A378TipAut = AV12Estado ;
            A384TipAut = AV13Usuari ;
            A382TipAut = GXutil.serverDate( context, remoteHandle, "DEFAULT") ;
            A383TipAut = GXutil.serverTime( context, remoteHandle, "DEFAULT") ;
            AV9Pout = (byte)(1) ;
            /* Using cursor P00135 */
            pr_default.execute(3, new Object[] {A377TipAut, A378TipAut, A384TipAut, A382TipAut, A383TipAut, new Byte(A376TipAut)});
            /* Check if program is canceled. */
            /* Exiting from a For First loop. */
            if (true) break;
         }
         pr_default.close(2);
      }
      cleanup();
   }

   protected void cleanup( )
   {
      this.aP5[0] = pmodreg.this.AV9Pout;
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      AV9Pout = 0 ;
      P00132_A523CmbCod = new int[1] ;
      P00132_A578CmbNom = new String[] {""} ;
      P00132_A579CmbEst = new String[] {""} ;
      P00132_A585CmbUUM = new String[] {""} ;
      P00132_A583CmbFUM = new java.util.Date[] {GXutil.nullDate()} ;
      P00132_A584CmbHUM = new String[] {""} ;
      A523CmbCod = 0 ;
      A578CmbNom = "" ;
      A579CmbEst = "" ;
      A585CmbUUM = "" ;
      A583CmbFUM = GXutil.nullDate() ;
      A584CmbHUM = "" ;
      P00134_A376TipAut = new byte[1] ;
      P00134_A377TipAut = new String[] {""} ;
      P00134_A378TipAut = new String[] {""} ;
      P00134_A384TipAut = new String[] {""} ;
      P00134_A382TipAut = new java.util.Date[] {GXutil.nullDate()} ;
      P00134_A383TipAut = new String[] {""} ;
      A376TipAut = 0 ;
      A377TipAut = "" ;
      A378TipAut = "" ;
      A384TipAut = "" ;
      A382TipAut = GXutil.nullDate() ;
      A383TipAut = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new pmodreg__default(),
         new Object[] {
             new Object[] {
            P00132_A523CmbCod, P00132_A578CmbNom, P00132_A579CmbEst, P00132_A585CmbUUM, P00132_A583CmbFUM, P00132_A584CmbHUM
            }
            , new Object[] {
            }
            , new Object[] {
            P00134_A376TipAut, P00134_A377TipAut, P00134_A378TipAut, P00134_A384TipAut, P00134_A382TipAut, P00134_A383TipAut
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private byte AV9Pout ;
   private byte A376TipAut ;
   private short Gx_err ;
   private int AV8Codigo ;
   private int A523CmbCod ;
   private String AV11Descri ;
   private String AV12Estado ;
   private String AV13Usuari ;
   private String AV10Tabla ;
   private String A578CmbNom ;
   private String A579CmbEst ;
   private String A585CmbUUM ;
   private String A584CmbHUM ;
   private String A377TipAut ;
   private String A378TipAut ;
   private String A384TipAut ;
   private String A383TipAut ;
   private java.util.Date A583CmbFUM ;
   private java.util.Date A382TipAut ;
   private byte[] aP5 ;
   private IDataStoreProvider pr_default ;
   private int[] P00132_A523CmbCod ;
   private String[] P00132_A578CmbNom ;
   private String[] P00132_A579CmbEst ;
   private String[] P00132_A585CmbUUM ;
   private java.util.Date[] P00132_A583CmbFUM ;
   private String[] P00132_A584CmbHUM ;
   private byte[] P00134_A376TipAut ;
   private String[] P00134_A377TipAut ;
   private String[] P00134_A378TipAut ;
   private String[] P00134_A384TipAut ;
   private java.util.Date[] P00134_A382TipAut ;
   private String[] P00134_A383TipAut ;
}

final class pmodreg__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("P00132", "SELECT [CmbCod], [CmbNom], [CmbEst], [CmbUUM], [CmbFUM], [CmbHUM] FROM [MMCMB10] WITH (UPDLOCK) WHERE [CmbCod] = ? ",true, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,true )
         ,new UpdateCursor("P00133", "UPDATE [MMCMB10] SET [CmbNom]=?, [CmbEst]=?, [CmbUUM]=?, [CmbFUM]=?, [CmbHUM]=?  WHERE [CmbCod] = ?", GX_NOMASK + GX_MASKLOOPLOCK)
         ,new ForEachCursor("P00134", "SELECT [TipAutCod], [TipAutNom], [TipAutEst], [TipAutUUM], [TipAutFUM], [TipAutHUM] FROM [MMTAU10] WITH (UPDLOCK) WHERE [TipAutCod] = ? ",true, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,true )
         ,new UpdateCursor("P00135", "UPDATE [MMTAU10] SET [TipAutNom]=?, [TipAutEst]=?, [TipAutUUM]=?, [TipAutFUM]=?, [TipAutHUM]=?  WHERE [TipAutCod] = ?", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((int[]) buf[0])[0] = rslt.getInt(1) ;
               ((String[]) buf[1])[0] = rslt.getString(2, 50) ;
               ((String[]) buf[2])[0] = rslt.getString(3, 1) ;
               ((String[]) buf[3])[0] = rslt.getString(4, 10) ;
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(5) ;
               ((String[]) buf[5])[0] = rslt.getString(6, 8) ;
               break;
            case 2 :
               ((byte[]) buf[0])[0] = rslt.getByte(1) ;
               ((String[]) buf[1])[0] = rslt.getString(2, 20) ;
               ((String[]) buf[2])[0] = rslt.getString(3, 1) ;
               ((String[]) buf[3])[0] = rslt.getString(4, 10) ;
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(5) ;
               ((String[]) buf[5])[0] = rslt.getString(6, 8) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               stmt.setInt(1, ((Integer) parms[0]).intValue());
               break;
            case 1 :
               stmt.setString(1, (String)parms[0], 50);
               stmt.setString(2, (String)parms[1], 1);
               stmt.setString(3, (String)parms[2], 10);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setInt(6, ((Integer) parms[5]).intValue());
               break;
            case 2 :
               stmt.setInt(1, ((Integer) parms[0]).intValue());
               break;
            case 3 :
               stmt.setString(1, (String)parms[0], 20);
               stmt.setString(2, (String)parms[1], 1);
               stmt.setString(3, (String)parms[2], 10);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setByte(6, ((Byte) parms[5]).byteValue());
               break;
      }
   }

}

